<!DOCTYPE html>
    <header>
        <meta charset="UTF-8">
        <title>个人信息系统11</title>
        <style>
            .wrap {
                margin-top: 150px;
                text-align: center;
            }
        </style>
    </header>
    <body>
        <div class="wrap">
            <div id="userName"></div>
            <button id="btnLogout">登出</button>
        </div>
        <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
        <script src="/js-cookie.js"></script>

        <script>
            $(document).ready(function () {
//                $.ajax({
//                    url: '/profile',
//                    type: 'GET',
//                    dataType: 'json',
//                    success: function (res) {
//                        $('#userName').html(res.userName);
//                    }
//                })
                $.ajax({
                    url: 'http://wthrcdn.etouch.cn/weather_mini?citykey=101210701',
                    type: 'GET',
                    dataType: 'json',
                    success: function (res) {
                        console.log(res);
                        $('#userName').html('今日气温：'+res.data.city + res.data.wendu+'度 '+
                                ',' + res.data.ganmao);
                    }
                })

                $('#btnLogout').click(function () {
                    $.ajax({
                        url: 'http://localhost:63342/PHP/logout.php?_ijt=7f48qni7llau4i6dd7e9d9r8j1',
                        type: 'GET',
                        contentType: 'application/json;charset=utf-8',
                        success: function (res) {
                            if (res.message === 'success') {
                                location.href = './login.html';
                            }
                        }
                    })
                })
            })
        </script>
    </body>
</html>
